package com.qingxin.ui.bean;

import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Vector;

/**
 * UI布局配置对象
 */
public class UILayout {
	
	private UILayoutLeft layoutLeft;
	private List<UILayoutCenter> layoutCenters = new Vector<>();
	private Map<String, UILayoutCenter> centerMap = new Hashtable<>();
	
	public UILayoutLeft getLayoutLeft() {
		return layoutLeft;
	}
	public void setLayoutLeft(UILayoutLeft layoutLeft) {
		this.layoutLeft = layoutLeft;
	}
	
	public List<UILayoutCenter> getLayoutCenters() {
		return layoutCenters;
	}
	public void addLayoutCenter(UILayoutCenter layoutCenter){
		layoutCenters.add(layoutCenter);
		centerMap.put(layoutCenter.getDatatype().toLowerCase(), layoutCenter);
	}
	public UILayoutCenter getLayoutCenter(String datatype, String lefttab){
		UILayoutCenter layoutCenter = centerMap.get(datatype.toLowerCase()+"@"+lefttab.toLowerCase());
		if(layoutCenter != null){
			return layoutCenter;
		}
		return centerMap.get(datatype.toLowerCase());
	}
	
	public void mergeUILayout(UILayout layout){
		if(layout ==null){
			return;
		}
		List<UILayoutCenter> centers = layout.getLayoutCenters();
		for(UILayoutCenter center : centers){
			addLayoutCenter(center);
		}
		
	}
	
	
}
